package com.nacos.config.configuration;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;

import java.io.IOException;
import java.util.Properties;

/**
 * @author chn
 * @Feature: 删除配置
 * @version 1.0
 * @data 2024/9/12 12:00
 */
public class deleteConfiguration {
    public static void main(String[] args) throws NacosException, IOException {
        Properties properties = new Properties();
        properties.put("serverAddr", "localhost:8848");
        properties.put("username", "nacos");
        properties.put("password", "nacos");

        // 初始化配置配置中心服务和命名服务
        ConfigService configService = NacosFactory.createConfigService(properties);
        NamingService namingService = NacosFactory.createNamingService(properties);

        // 删除配置
        boolean removeConfig = configService.removeConfig("application.yml", "DEFAULT_GROUP");
        System.out.println(removeConfig);
    }
}
